package routes

import (
	"github.com/goravel/framework/contracts/route"
	"github.com/goravel/framework/facades"
	"goravel/app/http/controllers"
)

func Api() {
	// 不需要登录的路由
	facades.Route().Prefix("/api").Group(func(router route.Router) {

		// 登录和登出接口
		authController := controllers.NewAuthController()
		router.Post("/auth/login", authController.Login)
		router.Post("/auth/logout", authController.Logout)
		router.Get("/auth/captcha", authController.Captcha)

		// })
		//需要登录的路由
		// facades.Route().Prefix("/api").Middleware(middleware.JwtAuth()).Group(func(router route.Router) {

		// 刷新token和获取用户信息接口
		// authController := controllers.NewAuthController()

		router.Post("/auth/refresh", authController.RefreshToken)
		router.Get("/auth/info", authController.Info)
		router.Put("/auth/edit", authController.Edit)

		// 系统用户接口
		userController := controllers.NewUserController()
		router.Get("/user", userController.List)
		router.Get("/user/{id}", userController.Show)

		// 系统管理员接口
		sysUserController := controllers.NewSysUserController()
		router.Resource("/sys_user", sysUserController)

		// 系统角色接口
		roleController := controllers.NewRoleController()
		router.Resource("/sys_role", roleController)

		// 系统数据字典及数据字典项接口
		dictController := controllers.NewDictController()
		router.Resource("/sys_dict", dictController)
		dictDataController := controllers.NewDictDataController()
		router.Resource("/sys_dict_data/{dict_slug}", dictDataController)

		// 系统登录日志列表和新增接口
		loginLogController := controllers.NewLoginLogController()
		router.Get("/login_log", loginLogController.Index)

		// 系统操作日志列表和新增接口
		sysOperateController := controllers.NewSysOperateLogController()
		router.Get("/sys_operate_log", sysOperateController.Index)
		router.Get("/sys_operate_log/{id}", sysOperateController.Show)
		router.Post("/sys_operate_log", sysOperateController.Store)

		// 系统菜单接口
		menuController := controllers.NewMenuController()
		router.Resource("/sys_menu", menuController)

		// 系统配置接口
		sysConfigController := controllers.NewSysConfigController()
		router.Resource("/sys_config", sysConfigController)

		// 系统通知接口
		notificationController := controllers.NewNotificationController()
		router.Resource("/notification", notificationController)

		// 分类管理接口
		categoryController := controllers.NewCategoryController()
		router.Resource("/category/{biz}/", categoryController)

		// 文件管理接口
		fileController := controllers.NewFileController()
		router.Resource("/file", fileController)

		// 短视频接口
		shortVideoController := controllers.NewShortVideoController()
		router.Resource("/short_video", shortVideoController)

	})
}
